package com.dapeng.cleardatabackend.model.vo;

import com.dapeng.cleardatabackend.model.entity.Relation;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;

/**
 * @author dapeng
 * @description 关系VO
 * @date 2024/12/22 22:46
 */
@Data
@ApiModel(description = "关系VO")
public class RelationVO implements Serializable {

    private static final long serialVersionUID = 431319699180079952L;

    /**
     * 关系id
     */
    @ApiModelProperty(value = "关系id")
    private Long id;

    /**
     * 前键用户定义id
     */
    @ApiModelProperty(value = "前键用户定义id")
    private String startNodeId;

    /**
     * 前键文本
     */
    @ApiModelProperty(value = "前键文本")
    private String startNodeText;

    /**
     * 关系
     */
    @ApiModelProperty(value = "关系")
    private String relationText;

    /**
     * 后键用户定义id
     */
    @ApiModelProperty(value = "后键用户定义id")
    private String endNodeId;

    /**
     * 后键文本
     */
    @ApiModelProperty(value = "后键文本")
    private String endNodeText;

    /**
     * 对象转视图
     *
     * @param relation 关系
     * @return {@link RelationVO }
     */
    public static RelationVO beanToVo(Relation relation) {
        RelationVO relationVO = new RelationVO();
        BeanUtils.copyProperties(relation, relationVO);
        return relationVO;
    }

}
